//#include "fdht_global.h"
//#include "fdht_client.h"
int main(int argc, char *argv[])
{
	char *conf_filename;
	int result;
	int expires;
	FDHTKeyInfo key_info;
	char szValue[256];
	int value_len;

	conf_filename = "/home/z/conf/fdht/parser_fdht_client.conf";

	if ((result=fdht_client_init(conf_filename)) != 0)
	{
		return result;
	}
	srand(time(NULL));
	expires = time(NULL) + 3600;
	memset(&key_info, 0, sizeof(key_info));
	key_info.namespace_len = sprintf(key_info.szNameSpace, "bbs");
	key_info.obj_id_len = sprintf(key_info.szObjectId, "o%d", rand());
	key_info.key_len = sprintf(key_info.szKey, "k%d", rand());

	while(1)
	{
		char *value;
		value_len = sprintf(szValue, "%d", rand());

		if ((result=fdht_set(&key_info, expires, szValue, value_len)) != 0)
		{
			break;
		}

		value_len = sizeof(szValue);
		if ((result=fdht_inc(&key_info, expires, 100, szValue, &value_len)) != 0)
		{
			break;
		}

		value = szValue;
		value_len = sizeof(szValue);
		if ((result=fdht_get_ex(&key_info, expires, &value, &value_len)) != 0)
		{
			printf("result=%d\n", result);
			break;
		}

		printf("value_len: %d\n", value_len);
		printf("value: %s\n", value);
		if ((result=fdht_delete(&key_info)) != 0)
		{
			break;
		}
		break;
	}


	fdht_client_destroy();
	return result;
}

